package tech.edwardvan.springbootdemo.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;
import tech.edwardvan.springbootdemo.condition.DemoCondition;
import tech.edwardvan.springbootdemo.imports.DemoImportBeanDefinitionRegistrar;
import tech.edwardvan.springbootdemo.imports.DemoImportSelector;
import tech.edwardvan.springbootdemo.properties.DemoProperties;

/**
 * 配置类
 *
 * @author EdwardVan
 */
@Configuration
@Conditional(DemoCondition.class)//自定义条件配置
@EnableConfigurationProperties(DemoProperties.class)//将DemoProperties加入到ioc容器中
@Import({DemoImportSelector.class, DemoImportBeanDefinitionRegistrar.class})
public class DemoConfiguration {

    DemoProperties demoProperties;

    /**
     * 只有一个有参构造器的情况下,参数的值就会从容器中取值
     */
    public DemoConfiguration(DemoProperties demoProperties) {
        this.demoProperties = demoProperties;
    }
}
